/**
 * 20.1.8 创建
 * 21.2.5 重写检测方法intersectObject
 * 20211215:抽离出检测函数getIntersects
 */
import DragMeshConfig from "../drag/drag-config/drag-mesh-config";
import RigidBody from "../../collision-detection/rigid-body";

/**
 * 碰撞体的拖动配置
 */
export default class DragRigidConfig extends DragMeshConfig{
    constructor(values={}){
        super(values);
    }
    get type(){
        return 'dragRigidConfig';
    }
    checkType(object) {
        let isRigid=object instanceof RigidBody;
        let isRigidBody=object.userData.rigid!==undefined&&object.userData.rigid!==null;
        return isRigid||isRigidBody;
    }

    getIntersects(object, out = []) {
        let obj=object instanceof RigidBody?object:object.userData.rigid;
        this._raycaster.intersectObject(obj,false,out);
        return out;
    }
}